import {Pipe, PipeTransform} from '@angular/core';

@Pipe({
  name: 'dayPast'
})
export class DayPastPipe implements PipeTransform {

  transform(value: any, ...args: unknown[]): unknown {
    if (!value) {
      return '';
    }
    const time = +new Date() - +new Date(value);
    const day = parseInt((time / (1000 * 3600 * 24)).toString(), 0);
    return `${value}${day > 0 ? `(${day}天前)` : ''}`;
  }

}
